package Bytestreamzijie.Buffer;

import java.io.*;

public class BufferInputOut {
    //带有缓冲区的输入流,提高读取性能
    public static void a() throws IOException {
        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream("src/aa.txt"));
        int data;//内存变量
        while ((data = bufferedInputStream.read()) != -1) {
            System.out.println((char) data);
        }
    }

    //带有缓冲区的输出流
    public static void b() throws IOException {
        String data = "JIANA";
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream("src/aa.txt"));
        bufferedOutputStream.write(data.getBytes());
        bufferedOutputStream.flush();
        bufferedOutputStream.close();
    }

    public static void main(String[] args) throws IOException {
//        a();
        b();
    }
}
